package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.DoReminder;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "待办提醒")
public class DoReminderVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "提醒类型")
    private Integer type;

    @ApiModelProperty(value = "关联id")
    private Integer corrlelationId;

    @ApiModelProperty(value = "访问地址")
    private String urlAddress;

    @ApiModelProperty(value = "发送人id")
    private Integer fromId;

    @ApiModelProperty(value = "流程类型")
    private Integer operationType;

    @ApiModelProperty(value = "提醒人id")
    private Integer adminId;

    @ApiModelProperty(value = "0未读，1已读")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static DoReminder convert(DoReminderVO vo) {
        DoReminder entity = new DoReminder();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<DoReminder> convertList(List<DoReminderVO> list) {
        List<DoReminder> resultList = new ArrayList<>();
        for (DoReminderVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
